package com.huanzhidadi.singleweb.ai;

import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson2.JSONObject;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@Api(tags = "提示词解析")
@RequestMapping(value = "promptParse")
public class PromptParseController {

    @ApiOperation(value = "解析json中的图片提示词", notes = "解析json中的图片提示词")
    @RequestMapping(value = "/getImagePrompt", method = RequestMethod.POST)
    public String getImagePrompt(@RequestBody JSONObject jsonObject) {
        log.info(jsonObject.toString());
        String string = jsonObject.getString("response");
        String content = "";
        if (StrUtil.contains(string, "</think>")) {
            content = string.split("</think>")[1];
        } else {
            content = string;
        }
        return content;
    }
}
